package com.lifeng.controller;

import com.lifeng.common.Result;
import com.lifeng.db.DB;
import com.lifeng.dto.UserDto;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/user")
public class UserController {

    @RequestMapping("/save")
    public Result save(@RequestBody UserDto userDto){
        DB.save(userDto);
        return Result.success();
    }

    @RequestMapping("/getById")
    public Result getById(@RequestBody UserDto userDto){
        UserDto userDto1 = DB.getById(userDto.getId());
        return Result.success(userDto1);
    }

    @RequestMapping("/list")
    public Result list(){
        return Result.success(DB.list());
    }
}
